package com.ww.byteBuf;

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;

import java.nio.charset.Charset;

/**
 * @ClassName:
 * @author:
 * @Description:
 * @Date
 **/
//复制byteBuf
public class ByteBuf02 {
    public static void main(String[] args) {
        Charset charset=Charset.forName("UTF-8");
        ByteBuf buf= Unpooled.copiedBuffer("Netty in action rocks.",charset);
        //创建一个副本
        ByteBuf copy=buf.copy(0,15);
        System.out.println(copy.toString(charset));
        buf.setByte(0,(byte)'J');
        assert buf.getByte(0) == copy.getByte(0);
    }
}
